package com.example.bookstore.service.impl;

import com.example.bookstore.entity.Address;
import com.example.bookstore.entity.People;
import com.example.bookstore.entity.ShopCart;
import com.example.bookstore.mapper.PeopleMapper;
import com.example.bookstore.service.PeopleService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class PeopleServiceImpl implements PeopleService {

    @Resource
    private PeopleMapper peopleMapper;

    @Override
    public People Login(String username, String password) {
        People people = peopleMapper.Login(username, password);
        return people;
    }

    @Override
    public Integer Register(String username, String password) {
        Integer row = peopleMapper.Register(username, password);
        return row;
    }

    @Override
    public People findByUserName(String username) {
        People people = peopleMapper.findByUserName(username);
        return people;
    }

    @Override
    public ShopCart findByTwo(Integer uid, Integer id) {
        ShopCart shopCart = peopleMapper.findByTwo(uid, id);
        return shopCart;
    }

    @Override
    public Integer add(ShopCart shopCart) {
        Integer row = peopleMapper.add(shopCart);
        return row;
    }

    @Override
    public Integer updateByUidAndIid(Integer uid, Integer id) {
        Integer row = peopleMapper.updateByUidAndIid(uid, id);
        return row;
    }

    @Override
    public List<ShopCart> queryShopcart(Integer id){
        List<ShopCart> list = peopleMapper.queryShopcart(id);
        return list;
    }

    @Override
    public List<ShopCart> findSbAllShopCart(Integer id) {
        List<ShopCart> list = peopleMapper.findSbAllShopCart(id);
        return list;
    }



    @Override
    public Integer updateByUidAndIid2(Integer uid, Integer iid) {
        Integer row = peopleMapper.updateByUidAndIid2(uid, iid);
        return row;
    }

    @Override
    public Integer delete(Integer id) {
        Integer row = peopleMapper.delete(id);
        return row;
    }


    @Override
    public Integer setAddress(Integer userid, String address, String phone) {
        Integer row = peopleMapper.setAddress(userid, address, phone);
        return row;
    }

    @Override
    public Address findAddressByUserId(Integer id) {
        Address address = peopleMapper.findAddressByUserId(id);
        return address;
    }

    @Override
    public Integer updateAddress(Integer id, String address, String phone) {
        Integer row = peopleMapper.updateAddress(id, address, phone);
        return row;
    }

    @Override
    public Integer deleteBook(Integer id) {
        Integer row = peopleMapper.deleteBook(id);
        return row;
    }

    @Override
    public void cleanShopCart(Integer id) {
        peopleMapper.cleanShopCart(id);
    }

}
